package com.ruoyi.rva.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rva.domain.RvaProperty;
import com.ruoyi.rva.service.IRvaPropertyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 属性Controller
 * 
 * @author jiaodacailei
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/rva/property")
public class RvaPropertyController extends BaseController
{
    @Autowired
    private IRvaPropertyService rvaPropertyService;

    /**
     * 查询属性列表
     */
    @PreAuthorize("@ss.hasPermi('rva:property:list')")
    @GetMapping("/list")
    public TableDataInfo list(RvaProperty rvaProperty)
    {
        startPage();
        List<RvaProperty> list = rvaPropertyService.selectRvaPropertyList(rvaProperty);
        return getDataTable(list);
    }

    /**
     * 导出属性列表
     */
    @PreAuthorize("@ss.hasPermi('rva:property:export')")
    @Log(title = "属性", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RvaProperty rvaProperty)
    {
        List<RvaProperty> list = rvaPropertyService.selectRvaPropertyList(rvaProperty);
        ExcelUtil<RvaProperty> util = new ExcelUtil<RvaProperty>(RvaProperty.class);
        return util.exportExcel(list, "属性数据");
    }

    /**
     * 获取属性详细信息
     */
    @PreAuthorize("@ss.hasPermi('rva:property:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(rvaPropertyService.selectRvaPropertyById(id));
    }

    /**
     * 新增属性
     */
    @PreAuthorize("@ss.hasPermi('rva:property:add')")
    @Log(title = "属性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RvaProperty rvaProperty)
    {
        return toAjax(rvaPropertyService.insertRvaProperty(rvaProperty));
    }

    /**
     * 修改属性
     */
    @PreAuthorize("@ss.hasPermi('rva:property:edit')")
    @Log(title = "属性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RvaProperty rvaProperty)
    {
        return toAjax(rvaPropertyService.updateRvaProperty(rvaProperty));
    }

    /**
     * 删除属性
     */
    @PreAuthorize("@ss.hasPermi('rva:property:remove')")
    @Log(title = "属性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(rvaPropertyService.deleteRvaPropertyByIds(ids));
    }
}
